public class Clip {

    public int value;
    public Cartridge[] cartridges;

    public int index;

    public Clip() {
    }


    public Clip(int value) {
        this.value = value;
        this.cartridges = new Cartridge[value];
    }

    // 装子弹
    public boolean pushCartridge(Cartridge cartridge) {
        if (index == value) {
            return false;
        } else {
            cartridges[index++] = cartridge;
            return true;
        }
    }

    // 弹出子弹
    public Cartridge popCartridge() {
        if (index == 0) {
            return null;// 返回一个空
        }
        return cartridges[--index];
    }
}
